package com.design.structure.adapter.atguigu.objectadapter;

/**
 * @ProjectName: design
 * @Package: com.design.structure.adapter.atguigu.classadapter
 * @ClassName: VoltageAdapter
 * @Author: shenaiguo
 * @Description: 适配器类
 * @Date: 2020/8/31 0031 23:00
 */
//步骤3
public class VoltageAdapter implements IVoltage5V {
    private Voltage220V voltage220V; // 关联关系-聚合

    //通过构造器，传入一个 Voltage220V 实例
    public VoltageAdapter(Voltage220V voltage220v) {


        this.voltage220V = voltage220v;
    }

    @Override
    public int output5V() {
        int dst = 0;
        if (null != voltage220V) {
            //获取 220V 电压
            int src = voltage220V.output220V();
            System.out.println("使用对象适配器，进行适配~~");
            dst = src / 44;
            System.out.println("适配完成，输出的电压为=" + dst);
        }
        return dst;
    }

}
